/**
 * Upper case first char
 * @param {String} string
 */
export default function asCurrency(number, decimal = 2) {
  let priceNumber = number
  if (typeof priceNumber === 'string') {
    priceNumber = priceNumber.replace(/[^-?\d.]/gi, '')
  }
  var price = parseFloat(priceNumber)
  if (isNaN(price)) {
    return number
  }
  if (decimal === false) {
    return price
  }
  return price.toFixed(decimal).toString()
}
